package com.kuang.blog.controller;


import com.kuang.blog.entity.User;
import com.kuang.blog.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 用户管理接口
 *
 * @author liujiaqi
 * @date 2023/02/27
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;

    /**
     * 查询用户列表
     *
     * @return {@link List}<{@link User}>
     */
    @GetMapping("/list")
    public List<User> queryUserList() {
        List<User> userList = userService.list(null);
        userList.forEach(System.out::println);
        return userList;
    }

    /**
     * 根据用户id重新用户
     *
     * @param id id
     * @return {@link User}
     */
    @GetMapping("/get/{id}")
    public User selectUserById(@PathVariable("id") Integer id ){
        return  userService.getById(id);
    }
}

